package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class BorrowedOperation implements IOperation{
    public void work(BookList bookList){
        Scanner sc=new Scanner(System.in);
        System.out.println("借出图书");
        System.out.println("输入要借出的图书名:");
        String name=sc.nextLine();
        int size= bookList.getUsedsize();
        int i=0;
        for(i=0;i<size;i++){
            Book book=bookList.getBook(i);
            if(book.getName().equals(name)){
                if(book.getisBorrowed()==true){
                    System.out.println("这本书已经借出");
                    return;
                }else{
                    book.setBorrowed(true);
                    System.out.println("成功借出："+name);
                }

            }
            if(i>=size){
                System.out.println("没有这本书!");
                return;
            }
        }
    }

}
